package com.jiang.专题.贪心.Q376;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/03/05 0:26
 */
class Solution {
    public int wiggleMaxLength(int[] nums) {
        int n = nums.length;

        if (n == 1) return 1;

        int up = 1, down = 1;
        for (int i = 1; i < n; i++) {
            if (nums[i] > nums[i - 1]) {
                up = down + 1;
            } else if (nums[i] < nums[i - 1]) {
                down = up + 1;
            }
        }
        return Math.max(down, up);
    }
}
